LAB 2¶

Name: Raghavendra Deshmukh | Student ID: 8854506¶

In [1]:
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
  1. Line Graph using Matpltlib.subplots
In [2]:
fig, ax = plt.subplots()  # Create a figure containing a single axes.
ax.plot([1, 2, 3, 4,5], [1, 4, 10, 3,-15])  # Plot some data on the axes.
Out[2]:
[<matplotlib.lines.Line2D at 0x2007bd435e0>]
  1. Line Graph using Matpltlib.subplots
In [4]:
x = np.linspace(0, 2, 100)  # Sample data.

# Note that even in the OO-style, we use `.pyplot.figure` to create the Figure.
fig, ax = plt.subplots(figsize=(5, 2.7))
ax.plot(x, x, label='linear')  # Plot some data on the axes.
ax.plot(x, x**2, label='quadratic')  # Plot more data on the axes...
ax.plot(x, x**3, label='cubic')  # ... and some more.
ax.set_xlabel('x label')  # Add an x-label to the axes.
ax.set_ylabel('y label')  # Add a y-label to the axes.
ax.set_title("Simple Plot")  # Add a title to the axes.
ax.legend()  # Add a legend.
Out[4]:
<matplotlib.legend.Legend at 0x2007bf85460>
  1. Line Graph using seaborn package

reference: https://seaborn.pydata.org/examples/index.html

In [5]:
import seaborn as sns
sns.set_theme(style="darkgrid")

# Load an example dataset with long-form data
fmri = sns.load_dataset("fmri")

# Plot the responses for different events and regions
sns.lineplot(x="timepoint", y="signal",
             hue="region", style="event",
             data=fmri)
Out[5]:
<AxesSubplot:xlabel='timepoint', ylabel='signal'>
  1. Scatter Graph using plotly
In [8]:
import plotly.express as px
df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species",
                 size='petal_length', hover_data=['petal_width'])
fig.show()